
/**
 * AppleIIGo
 * Videx Videoterm class
 * (C) 2008 by Marc S. Ressl (mressl@umich.edu)
 * Released under the GPL
 */

#ifndef VIDEOTERM_H
#define VIDEOTERM_H

#define VIDEOTERM_ROM_BYTENUM 0x400

typedef enum {
	VIDEOTERM_HORIZ,
	VIDEOTERM_HORIZDISP,
	VIDEOTERM_HORIZSYNCPOS,
	VIDEOTERM_HORIZSYNCWIDTH,
	VIDEOTERM_VERT,
	VIDEOTERM_VERTDISP,
	VIDEOTERM_VERTSYNCPOS,
	VIDEOTERM_VERTSYNCWIDTH,
	VIDEOTERM_INTERLACED,
	VIDEOTERM_MAXSCANLINE,
	VIDEOTERM_CURSORUPPER,
	VIDEOTERM_CURSORLOWER,
	VIDEOTERM_STARTPOSHIGH,
	VIDEOTERM_STARTPOSLOW,
	VIDEOTERM_CURSORHIGH,
	VIDEOTERM_CURSORLOW,
	VIDEOTERM_LIGHTPENHIGH,
	VIDEOTERM_LIGHTPENLOW,
	VIDEOTERM_INVALID,
	VIDEOTERM_END,
};

#include "SlotDevice.h"

class Videoterm : public SlotDevice {
public:
	Videoterm(class Motherboard * motherboard, char * slotDeviceName);
	
	void onDevicesConnected();
	void onMemoryRequested();
	void onMemoryAllocated();
	void onResetAsserted(bool isRestart);
	
	void writeIo(UINT16 address, UINT8 value);
	UINT8 readIo(UINT16 address);
	
	void writeMemory(UINT16 address, UINT8 value);
	UINT8 readMemory(UINT16 address);
	
private:
	UINT32 romMemoryOffset;
	UINT8 * romMemory;
	UINT8 * shadowMemory;
	UINT32 shadowMemoryOffset;
	
	UINT8 videotermRegisterIndex;
	UINT8 videotermRegister[VIDEOTERM_END];
	UINT8 bankRegister;
	
	void setBankRegister(UINT8 value);
};

#endif
